package com.qianbao.qianbaobusiness.ui.push;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.androidbase.base.BaseActivity;
import com.androidbase.utils.StatusBarHelper;
import com.baseandroid.event.MsgReadEvent;
import com.baseandroid.utils.FormatUtil;
import com.qianbao.qianbaobusiness.R;
import com.qianbao.qianbaobusiness.json.MessageListBean;

import org.greenrobot.eventbus.EventBus;

public class MessageDetailsActivity extends BaseActivity {

    RelativeLayout toolbar_back;
    TextView toolbar_title;
    TextView msg_detils_title_tv;
    TextView msg_detils_date_tv;
    TextView msg_detils_content_tv;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_message_detail_layout;
    }

    @Override
    protected void setupView() {
        StatusBarHelper.translateStatusBar(this);
        toolbar_back = findViewById(R.id.toolbar_back);
        toolbar_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        toolbar_title = findViewById(R.id.toolbar_title);
        toolbar_title.setText(R.string.message_detail_titile);

        msg_detils_title_tv = findViewById(R.id.msg_detils_title_tv);
        msg_detils_date_tv = findViewById(R.id.msg_detils_date_tv);
        msg_detils_content_tv = findViewById(R.id.msg_detils_content_tv);
    }

    @Override
    protected void setupData(Bundle savedInstanceState) {
        MessageListBean.ResultItem resultItem = (MessageListBean.ResultItem) getIntent().getSerializableExtra("resultItem");
        if (resultItem.getReadstatus().equals("0")) {
            EventBus.getDefault().post(new MsgReadEvent());
        }
        if (resultItem != null) {
            msg_detils_title_tv.setText(resultItem.getTitle());
            msg_detils_date_tv.setText(FormatUtil.changeTime(resultItem.getSendstarttime(), "yyyy/MM/dd HH:mm"));
            msg_detils_content_tv.setText(resultItem.getContent());
        }
    }

}
